﻿using Hardcodet.Wpf.TaskbarNotification;
using SharpCopy.Util;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;

namespace SharpCopy.Controller
{
    class NotificationController
    {
        #region Private members

        static TaskbarIcon OTaskbarIcon;

        #endregion

        #region ctor

        public NotificationController()
        {
            _ExitCommand = new DelegateCommand(DoExit, CanExit);

            OTaskbarIcon = new TaskbarIcon();

            OTaskbarIcon.Icon = new Icon(this.GetType().Assembly.GetManifestResourceStream("SharpCopy.Resources.Icon.ico"));
            OTaskbarIcon.ToolTipText = "SharpCopy";
            System.Windows.Controls.ContextMenu contextmenu = new System.Windows.Controls.ContextMenu();
            contextmenu.Items.Add(new MenuItem() { Header = "Exit", Command = _ExitCommand });
            OTaskbarIcon.ContextMenu = contextmenu;
        }

        #endregion

        #region Static methods

        public static void ShowInfoBallonTip(string title, string message)
        {
            OTaskbarIcon.ShowBalloonTip(title, message, BalloonIcon.Info);
        }

        public static void ShowErrorBallonTip(string title, string message)
        {
            OTaskbarIcon.ShowBalloonTip(title, message, BalloonIcon.Error);
        }

        #endregion

        #region Exit Command

        private DelegateCommand _ExitCommand;
        /// <summary>
        /// Application Exit Command
        /// </summary>
        public DelegateCommand ExitCommand
        {
            get { return _ExitCommand; }
        }

        private void DoExit(object parameter)
        {
            System.Windows.Application.Current.Shutdown(0);
        }

        private bool CanExit(object parameter)
        {
            return true;
        }

        #endregion

    }
}
